{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.instrument import IRXccySwap, IRXccySwapFixFix\n",
    "from gs_quant.risk import Cashflows\n",
    "from gs_quant.session import Environment, GsSession\n",
    "\n",
    "# external users should substitute their client id and secret\n",
    "client_id = None # Supply your application id\n",
    "client_secret = None # Supply your client secret\n",
    "\n",
    "GsSession.use(Environment.PROD, client_id=client_id, client_secret=client_secret, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Create a Xccy float vs float Swap and a Xccy fix vs fix swap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "mtm_swap = IRXccySwap(payer_currency='EUR', receiver_currency='USD', effective_date='3m', termination_date='10y')\n",
    "fix_swap = IRXccySwapFixFix(payer_currency='EUR', receiver_currency='USD', termination_date='10y', payer_rate=0.01, receiver_rate=0.015)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compute cashflows for the 10y EURUSD fix swap "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cf_fix = fix_swap.calc(Cashflows)\n",
    "cf_fix.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compute cashflows for the forward starting 10y EURUSD float float swap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "mtm_swap.calc(Cashflows).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Clone the float float swap keeping spread constant but modifying the rate applied at initiation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "mtm_swap = mtm_swap.clone(initial_fx_rate=1.2, payer_spread=mtm_swap.payer_spread)\n",
    "mtm_swap.calc(Cashflows).head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
